import os
from StatStruct import StatStruct
from Verbosity import Verbosity

class MyTypeBase:
	"""Base class for my-fuse-types. Gives functionality which is used
	in WhateverFuse. Should be derived and methods if need overwritten."""

	def __init__(self):
		"""Constructor, initializes basic functionality with basic values."""

		self.verbosity=Verbosity(False, "* "+str(self.__class__)+": ")
	# End def

	def getStatStruct(self, path):
		"""Should returns the directory-stat-structure from StatStruct/fuse.stat."""

		self.verbosity.out("getStatStruct: path: %s" % path)

		st=StatStruct()
		return st
	# End def

	def hasPath(self, path):
		"""Should return true if the given path exists or false if not."""

		self.verbosity.out("hasPath: path: %s" % path)

		return False
	# End def

	def getPathEntries(self, path):
		"""Should return an array with entries from the given path."""

		self.verbosity.out("getPathEntries: path: %s" % path)

		return []
	# End def

	def getSizeOf(self, path):
		"""Should return the size of the data under the given path."""

		self.verbosity.out("getSizeOf: path: %s" % path)

		return 0
	# End def

	def getLengthOf(self, path):
		"""Should return the length of the data under the given path."""

		self.verbosity.out("getLengthOf: path: %s" % path)

		return 0
	# End def

	def delData(self, path):
		"""Should delete the data under the given path."""
		
		self.verbosity.out("delData: path: %s" % path)

		pass
	# End def

	def getData(self, path):
		"""Should return the data under the given path."""

		self.verbosity.out("getData: path: %s" % path)

		return None
	# End def

	def setData(self, path, value):
		"""Should set the 'value' to the given 'path'."""

		self.verbosity.out("setData: path: %s, value: ..." % path)

		pass
	# End def

	def getEncoding(self):
		"""Should return the currently set encoding-type."""

		self.verbosity.out("getEncoding: encoding: %s" % self.__encoding)

		return self.__encoding
	# End def

	def setEncoding(self, encoding="latin1"):
		"""Defines how your given data is encoded and should be decoded on reading/-saving-process.
		Actually it's pretty hard to combine raw-text-data, utf-8/latin encoded text-data,
		binary-stored jpeg-data and so on, so it's recommended to take the default, latin1.

		Parameter:
			string encoding The encoding your is stored with.
		"""

		self.verbosity.out("setEncoding: encoding: %s" % encoding)

		if type(encoding)!=str: raise TypeError

		self.__encoding=encoding
	# End def

# End class
